#include "Thread.h"

// destructor
Thread::~Thread()
{
	assert(!corriendo);
	
}

void Thread::run()
{
	pthread_create(&idThread, NULL, static_run, this);
}

bool Thread::running() const
{
	return corriendo;
}

void Thread::join()
{
	pthread_join(idThread, NULL);
}

void Thread::sleep(unsigned long msecs)
{
	::usleep(msecs*1000);
}

void* Thread::static_run(void* arg)
{
	((Thread*)arg)->corriendo = true;
	((Thread*)arg)->main();
	((Thread*)arg)->corriendo = false;
	return NULL;
}
